package com.foo.common.base.utils;

import java.io.File;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;

import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import com.github.mustachejava.MustacheFactory;
import com.google.common.base.Charsets;
import com.google.common.collect.Maps;
import com.google.common.io.Files;

/**
 * Tomcat配置文件生成工具
 * 
 * @author Steve
 *
 */
public class TomcatConfigFileGeneratorHelper {

	private final static String tomcatConfigFilePath = "";

	private final static org.slf4j.Logger logger = org.slf4j.LoggerFactory
			.getLogger(TomcatConfigFileGeneratorHelper.class);

	public static void main(String[] args) throws Exception {

		MustacheFactory mf = new DefaultMustacheFactory();

		HashMap<String, Object> scopes = Maps.newHashMap();
		scopes.put("projectPath", "D:\\tools\\myGit\\tenmalife-platform");

		Mustache mustache = mf.compile("mustache/tomcat-config-file.xml");

		Writer writer = new StringWriter();

		mustache.execute(writer, scopes);
		writer.flush();

		logger.info("result is:{}", writer.toString());

		Files.write(writer.toString(), new File(tomcatConfigFilePath),
				Charsets.UTF_8);

	}

}
